package com.sicaolong.partterndesign._02strategy._02;

import java.util.Arrays;

public class Sorter<T> {

    public void sort(T[] arrays, MyComparator<T> comparator) {
        for (int i = 0; i < arrays.length; i++) {
            T min = arrays[i];
            int temp = i;
            for (int j = arrays.length - 1; j > i; j--) {
                if (comparator.compare(min, arrays[j]) > 0) {
                    min = arrays[j];
                    temp = j;
                }
            }
            arrays[temp] = arrays[i];
            arrays[i] = min;
        }
    }


}
